<html>
  <head>
    <title>QDox Usage</title>
  </head>
  <body>

		<h2>Entry Point</h2>

			<p><code><a href="apidocs/com/thoughtworks/qdox/JavaProjectBuilder.html">JavaProjectBuilder</a></code> is the entry point to
			QDox. It is responsible for parsing source code, resolving imports and storing
			the data.</p>

			<p>To create it, all you need to do is call the default constructor.</p>

<div class="Source Java"><pre>
JavaProjectBuilder builder = new JavaProjectBuilder();
</pre></div>


		<h2>Reading Source Files</h2>

			<p>Java source code can then be added to the
			<code><a href="apidocs/com/thoughtworks/qdox/JavaProjectBuilder.html">JavaProjectBuilder</a></code>.
			Source can either be read one file at a time (using a java.io.Reader) or an entire source tree
			can be added recursively.</p>

<div class="Source Java"><pre>
// Reading a single source file.
builder.addSource(new FileReader("MyFile.java"));

// Reading from another kind of input stream.
builder.addSource(new StringReader("package test; public class Hello {}"));

// Adding all .java files in a source tree (recursively).
builder.addSourceTree(new File("mysrcdir"));
</pre></div>

		<h2>Resolving Class Names</h2>

			<p>In order to resolve classes that have been imported using a wildcard (e.g. <code>import java.util.*;</code>), the
			<code><a href="apidocs/com/thoughtworks/qdox/library/ClassLibrary.html">ClassLibrary</a></code>
			must be aware of other classes used in the project.</p>

			<p>ClassLibrary has 4 ways to resolve classes:</p>

			<p><ul>
				<li>By looking at other sources that have been added.</li>
				<li>By searching through the supplied sourceFolders</li>
				<li>By looking in the current classpath (including the standard JRE classes).</li>
				<li>By looking at additional ClassLoaders specified at runtime.</li>
			</ul></p>

			<p>All sources and sourcetrees added to the JavaProjectBuilder will be parsed. This is often much more than required. 
			To increase efficiency use the ClassLibrary to add sourcefolders. Consider these files as lazy parsed sources.</p>

            <p>The current classpath is automatically set by JavaProjectBuilder. In most cases this shall be sufficient, however in some
            situations you may want resolve the full classes in external libraries.</p>

<div class="Source Java"><pre>
// Get the ClassLibrary
JavaProjectBuilder builder = new JavaProjectBuilder();

// Add a sourcefolder;
builder.addSourceFolder( new File( "src/main/java" ) );
builder.addSourceFolder( new File( "target/generated-sources/foobar" ) );

// Add a custom ClassLoader
builder.addClassLoader( myCustomClassLoader );

// Ant example : add the &lt;classpath&gt; element's contents
builder.addClassLoader( new AntClassLoader( getProject(), classpath ) );
</pre></div>

			<p>It is important that additional ClassLoaders are added before any source files are parsed.</p>

		<h2>Navigating The Model</h2>
			<p>Now the files have been parsed, move on to <a href="model.html">navigating the model</a>.</p>

	</body>
	
</html>
